using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;

namespace roster.Tests
{
    public static class EnumerableComparisonExtension
    {
        public static void CompareTo<T>(this IEnumerable<T> expected, IEnumerable<T> actual)
        {
            Assert.AreEqual(expected.Count(), actual.Count(), "Enumerables contain different number of elements.");

            IEnumerator<T> actualEnumerator = actual.GetEnumerator();
            IEnumerator<T> expectedEnumerator = expected.GetEnumerator();

            int position = 1;
            while (actualEnumerator.MoveNext())
            {
                expectedEnumerator.MoveNext();
                Assert.AreEqual(expectedEnumerator.Current, actualEnumerator.Current,
                                string.Format("Enumerator elements at position {0} do not match.", position));

                position++;
            }
        }
    }
}